//1,引入mysql模块
const mysql =require('mysql')
var connection=mysql.createConnection({
    hose:'127.0.0.1',
    port:'3306',
    user:'root',
    password:'root',
    database:'userDate'
})
//3,建立连接
connection.connect()
console.log('数据库连接成功');
//4,执行sql语句
// var uid=3
// var uname='abc'
// var upwd='1234'

// connection.query('insert into userinfo(uid,uname,upwd) values(?,?,?)',[uid,uname,upwd],function(err,result){
//     if(err) throw err
//     console.log(result)
// })

connection.query('select * from userinfo',function(err,result){
    if(err) throw err
    console.log(result)
})

// connection.query("delete from userinfo where uid=4 ",function(err,result){
//     if(err) throw err
//     console.log(result)
// })

// connection.query("insert into userinfo(uname,upwd) values('abcd','1234')",function(err,result){
//     if(err) throw err
//     console.log(result)
// })